/*
 * @Description: 
 * @Author: ouyaping
 * @Date: 2023-04-11 14:20:44
 * @LastEditors: ouyaping
 * @LastEditTime: 2023-04-14 12:52:36
 */
import { Controller, Get } from '@nestjs/common';
import { AppService } from './app.service';
import { GrpcMethod } from '@nestjs/microservices';

const list = {
  'ReportProfessionalRunningPostureRealTimeData': {},
  'ReportProfessionalJointLoadData': {},
  'ReportProfessionalRunningPostureJoints': {},
  'ReportProfessionalRunningPostureResultData': {}
}

@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get()
  async startAlg(): Promise<any> {
    list.ReportProfessionalRunningPostureRealTimeData = {}
    list.ReportProfessionalJointLoadData = {}
    list.ReportProfessionalRunningPostureJoints = {}
    list.ReportProfessionalRunningPostureResultData = {}
    const result = await this.appService.startAlg();

    return result
  }

  @Get('list')
  async getList(): Promise<any> {
    console.log(JSON.stringify(list))
    return list
  }

  @Get('end')
  async endAlg(): Promise<any> {
    const result = await this.appService.endAlg();
    return result
  }

  @GrpcMethod("Algorithm")
    async reportProfessionalRunningPostureStatus(data: { status: number }) {
        return true;
  }

  @GrpcMethod("Algorithm")
    async reportProfessionalRunningPostureRealTimeData(data: any) {
      list.ReportProfessionalRunningPostureRealTimeData = data
        return true;
  }

  @GrpcMethod("Algorithm")
    async reportProfessionalJointLoadData(data: any) {
        list.ReportProfessionalJointLoadData = data
        return true;
  }

  @GrpcMethod("Algorithm")
    async reportProfessionalRunningPostureJoints(data: any) {
        list.ReportProfessionalRunningPostureJoints = data
        return true;
  }

  @GrpcMethod("Algorithm")
    async reportProfessionalRunningPostureResultData(data: any) {
    list.ReportProfessionalRunningPostureResultData = data
    console.log('data=',data)
        return true;
  }
}
